Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: PRT: Add subscription metrics #1695

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

lyomagma
Copy link
Collaborator

@lyomagma lyomagma changed the title Prt add subscription metrics Prt feat: add subscription metrics Sep 15, 2024
@lyomagma lyomagma changed the title Prt feat: add subscription metrics PRT feat: add subscription metrics Sep 15, 2024
@lyomagma lyomagma changed the title PRT feat: add subscription metrics feat: PRT add subscription metrics Sep 15, 2024
@lyomagma lyomagma self-assigned this Sep 15, 2024
Copy link

github-actions bot commented Sep 15, 2024

Test Results

2 205 tests  ±0   2 205 ✅ ±0   24m 21s ⏱️ - 1m 1s
  145 suites ±0       0 💤 ±0 
    7 files   ±0       0 ❌ ±0 

Results for commit 08d53e8. ± Comparison against base commit 6278d1a.

♻️ This comment has been updated with latest results.

@shleikes shleikes changed the title feat: PRT add subscription metrics feat: PRT: Add subscription metrics Sep 15, 2024
@@ -190,6 +202,7 @@ func (cwsm *ConsumerWSSubscriptionManager) StartSubscription(
webSocketConnectionUniqueId string,
metricsData *metrics.RelayMetrics,
) (firstReply *pairingtypes.RelayReply, repliesChan <-chan *pairingtypes.RelayReply, err error) {
go cwsm.rpcConsumerLogs.SetRelaySubscriptionRequestMetric(metricsData.ChainID, metricsData.APIType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we want this here. Users might spam with false subscription message, which will increase this metric for nothing. Maybe move this to after validation?

Comment on lines 24 to 28
const (
ConsumerDisconnect RelayDisconnectReasonEnum = "ConsumerDisconnect"
ProviderDisconnect RelayDisconnectReasonEnum = "ProviderDisconnect"
UserDisconnect RelayDisconnectReasonEnum = "UserDisconnect"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to metrics, change to int enum, and use map

@@ -201,6 +204,7 @@ func (cwsm *ConsumerWSSubscriptionManager) StartSubscription(
utils.LogAttr("GUID", webSocketCtx),
utils.LogAttr("hashedParams", utils.ToHexString(hashedParams)),
utils.LogAttr("dappKey", dappKey),
utils.LogAttr("connectedDapps", cwsm.connectedDapps),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in main, why is is added back here?

Comment on lines 18 to 22
const (
ConsumerDisconnect WsDisconnectReasonEnum = iota
ProviderDisconnect WsDisconnectReasonEnum = iota
UserDisconnect WsDisconnectReasonEnum = iota
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You can do the = iota once in thins enum, as can be seen for example in provider_optimizer.go
  2. Please use upper case snake case for this enum
  3. Please prefix the enum items with WS_DISCONNECTION_REASON_

Comment on lines 24 to 28
var disconnectReasonMap = map[WsDisconnectReasonEnum]string{
ConsumerDisconnect: "ConsumerDisconnect",
ProviderDisconnect: "ProviderDisconnect",
UserDisconnect: "UserDisconnect",
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is only for logs, make the strings a bit more readable, like kebab-case

Comment on lines 111 to 112
Help: "The total number of websocket subscription requests by the consumer over time per chain id per api interface.",
}, []string{"spec", "apiInterface"})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Help: "The total number of websocket subscription requests by the consumer over time per chain id per api interface.",
}, []string{"spec", "apiInterface"})
Help: "The total number of websocket subscription requests over time per chain id per api interface.",
}, []string{"spec", "apiInterface"})


totalFailedWsSubscriptionRequestsMetric := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "lava_consumer_total_failed_ws_subscription_requests",
Help: "The total number of failed websocket subscription requests by the consumer over time per chain id per api interface.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Help: "The total number of failed websocket subscription requests by the consumer over time per chain id per api interface.",
Help: "The total number of failed websocket subscription requests over time per chain id per api interface.",


totalDuplicatedWsSubscriptionRequestsMetric := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "lava_consumer_total_duplicated_ws_subscription_requests",
Help: "The total number of duplicated webscket subscription requests by the consumer over time per chain id per api interface.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Help: "The total number of duplicated webscket subscription requests by the consumer over time per chain id per api interface.",
Help: "The total number of duplicated webscket subscription requests over time per chain id per api interface.",

Copy link
Collaborator Author

@lyomagma lyomagma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants